package Chapter01.Homework.Work02;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Company {
    private String name;
    private String address;
    private String telephone;
    private String scop;//经营范围
    Set<Employee> set=new HashSet<>();
    //添加员工
    public boolean add(Employee name){
        for (int i=0;i<set.size();i++){
            //员工号不能重复
            if(name.getId().equals(set.contains(i))){
                return false;
            }
        }
        set.add(name);
        return true;
    }

    //输出员工信息
    public void Message(){
        for (Object s:set){
            Employee n= (Employee) s;
            System.out.println(n);
        }
    }

    //公司人数
    public void people(){
        System.out.println(set.size());
    }

    //辞退员工
    public boolean resign(String id){
        for (Employee s:set){
            if(s.getId().equals(id)){
                set.remove(s);
                return true;
            }
        }
        return false;
    }

    //获得薪水最高的员工方法
    public Employee max(){
        Iterator<Employee> it=set.iterator();
        Employee em=it.next();
        for (Employee s:set){
            if(s.getSalary()<s.getSalary()){
                em=s;
            }
        }
        return em;
    }
    public void show(){
        System.out.println("公司名称"+name+",公司地址"+address+",电话"+telephone+",经营范围"+scop);
    }

    public Company(String name, String address, String telephone, String scop) {
        this.name = name;
        this.address = address;
        this.telephone = telephone;
        this.scop = scop;
    }
}
